import {FormFieldStore} from "@/components/Form";
import cloneDeep from "lodash/cloneDeep";
import {action, observable, computed} from 'mobx'

export class CheckBoxGroupStore extends FormFieldStore {
    @observable options = []

    constructor(props) {
        super(props)
        const {options} = props
        this.options = cloneDeep(options || [])
    }

    @action changeOptions(options) {
        this.options = options
    }

    @computed get computedValue() {
        const values = this.childrenValues
        const result = values.filter(t => t.checked).map(t => t.value).join(',')
        return result
    }
}